/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.marlboroug.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "Orders")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orders.findAll", query = "SELECT o FROM Orders o"),
    @NamedQuery(name = "Orders.findByIDorders", query = "SELECT o FROM Orders o WHERE o.iDorders = :iDorders"),
    @NamedQuery(name = "Orders.findByDateReceived", query = "SELECT o FROM Orders o WHERE o.dateReceived = :dateReceived"),
    @NamedQuery(name = "Orders.findByNetAmount", query = "SELECT o FROM Orders o WHERE o.netAmount = :netAmount"),
    @NamedQuery(name = "Orders.findByGrossAmount", query = "SELECT o FROM Orders o WHERE o.grossAmount = :grossAmount"),
    @NamedQuery(name = "Orders.findByStatus", query = "SELECT o FROM Orders o WHERE o.status = :status")})
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_orders")
    private Long iDorders;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date_received")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateReceived;
    @Basic(optional = false)
    @NotNull
    @Column(name = "net_amount")
    private float netAmount;
    @Basic(optional = false)
    @NotNull
    @Column(name = "gross_amount")
    private float grossAmount;
    @Basic(optional = false)
    @NotNull
    @Column(name = "status")
    private int status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOrders")
    private Collection<Articlesordered> articlesorderedCollection;
    @JoinColumn(name = "id_users", referencedColumnName = "ID_users")
    @ManyToOne(optional = false)
    private Users idUsers;

    public Orders() {
    }

    public Orders(Long iDorders) {
        this.iDorders = iDorders;
    }

    public Orders(Long iDorders, Date dateReceived, float netAmount, float grossAmount, int status) {
        this.iDorders = iDorders;
        this.dateReceived = dateReceived;
        this.netAmount = netAmount;
        this.grossAmount = grossAmount;
        this.status = status;
    }

    public Long getIDorders() {
        return iDorders;
    }

    public void setIDorders(Long iDorders) {
        this.iDorders = iDorders;
    }

    public Date getDateReceived() {
        return dateReceived;
    }

    public void setDateReceived(Date dateReceived) {
        this.dateReceived = dateReceived;
    }

    public float getNetAmount() {
        return netAmount;
    }

    public void setNetAmount(float netAmount) {
        this.netAmount = netAmount;
    }

    public float getGrossAmount() {
        return grossAmount;
    }

    public void setGrossAmount(float grossAmount) {
        this.grossAmount = grossAmount;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @XmlTransient
    public Collection<Articlesordered> getArticlesorderedCollection() {
        return articlesorderedCollection;
    }

    public void setArticlesorderedCollection(Collection<Articlesordered> articlesorderedCollection) {
        this.articlesorderedCollection = articlesorderedCollection;
    }

    public Users getIdUsers() {
        return idUsers;
    }

    public void setIdUsers(Users idUsers) {
        this.idUsers = idUsers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iDorders != null ? iDorders.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orders)) {
            return false;
        }
        Orders other = (Orders) object;
        if ((this.iDorders == null && other.iDorders != null) || (this.iDorders != null && !this.iDorders.equals(other.iDorders))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.marlboroug.entity.Orders[ iDorders=" + iDorders + " ]";
    }
    
}
